
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <script src="/static/layui/layui.js"></script>
    <script src="/static/jquery-latest.js"></script>
    <script src="/static/fun.js"></script>
</head>
<body>
<!--操作按钮模板-->

<form class="layui-form" action=""style="padding: 20px 40px">
    <div class="layui-form-item">
        <label class="layui-form-label">{{if eq $.status "0"}}学号{{else}}工号{{end}}</label>
        <label class="layui-form-label" style="text-align: left">{{.data.Number}}</label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">头像</label>
        <div class="layui-input-inline">
            <img src="{{.data.Avatar}}" style="width: 150px;height: 150px">
        </div>
        <div class="layui-input-inline layui-btn-container" style="width: auto;">
            <button type="button" class="layui-btn layui-btn-primary" id="LAY_avatarUpload">
                <i class="layui-icon"></i>上传图片
            </button><input class="layui-upload-file" type="file" accept="" name="file">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            {{if eq $.status "0"}}
            <input type="text" name="Name"disabled="disabled" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input" value="{{.data.Name}}">
            {{else}}
            <input type="text" name="Name" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input" value="{{.data.Name}}">
            {{end}}

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">年龄</label>
        <div class="layui-input-block">
            {{if eq $.status "0"}}
            <input type="text" name="Age"disabled="disabled" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input" value="{{.data.Age}}">
            {{else}}
            <input type="text" name="Age" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input" value="{{.data.Age}}">
            {{end}}

        </div>
    </div>
    {{if eq $.status "0"}}{{else}}
    <div class="layui-form-item">
        <label class="layui-form-label">预约地点</label>
        <div class="layui-input-block">
            <input type="text" name="booking_place" required  lay-verify="required" placeholder="请输入预约地点" autocomplete="off" class="layui-input" value="{{.data.BookingPlace}}">
        </div>
    </div>
    {{end}}
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            {{if eq $.data.Sex "男"}}
            <input type="radio" name="Sex" value="男" title="男" checked><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>男</div></div>
            <input type="radio" name="Sex" value="女" title="女" ><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>女</div></div>
            {{else}}
            <input type="radio" name="Sex" value="男" title="男" ><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>男</div></div>
            <input type="radio" name="Sex" value="女" title="女" checked ><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>女</div></div>
            {{end}}

        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="submit-button">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use("form",function (){
        var form = layui.form;
        form.on('submit(submit-button)',function (data){
            $.ajax({
                url:'/public/informationEdit/'+getCookie("Status")+'/'+getCookie("Id"),
                method:'post',
                data:data.field,
                dataType:'JSON',
                async: false,
                success:function(res){
                        layer.msg("提交成功",{icon: 1, time: 1000},function(){
                            window.location.reload()
                        }); //提交成功后刷新页面
                }
            });
            return false;
        })
    })
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#LAY_avatarUpload' //绑定元素
            ,url: '/public/uploadMessageImg/'+getCookie("Id") //上传接口
            ,data:{  // 文件上传的参数
                id: getCookie("Id"),
                Status:getCookie("Status"),
            }
            ,done: function(res){
                layer.msg(res.msg,{icon: res.icon, time: 1000},function(){
                    window.parent.location.reload()
                }); //提交成功后刷新页面
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });
</script>

</body>
